﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameLibrary.AI.ShortestPath
{
   public class AStarNode : IComparable<AStarNode>
    {
       public Position CurrentPosition;
       public List<Position> Path = new List<Position>();
       public double Value;

       public AStarNode(Position position, List<Position> path, double value)
       {
           this.CurrentPosition = position;
           this.Path.AddRange(path);
           this.Path.Add(this.CurrentPosition);
           this.Value = value;
       }

       public void ResetNode(List<Position> path, double value)
       {
           this.Path.Clear();
           this.Path.AddRange(path);
           this.Path.Add(this.CurrentPosition);
           this.Value = value;
       }

       #region IComparable<AStarNode> Members

       public int CompareTo(AStarNode other)
       {
           if (this.Value > other.Value)
               return 1;
           else
               if (this.Value < other.Value)
                   return -1;
               else
                   return 0;
       }

       #endregion
    }
}
